package com.nowcoder.community.service;

import com.nowcoder.community.dao.AlphaDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

/**
 * @author: caoxinfang
 * @email: 2717176337@qq.com
 * @date: 2022/3/6 20:38
 */
@Service
@Scope("prototype") // 每次创建bean都会创建一次新的实例
public class AlphaService {

    @Autowired
    private AlphaDao alphaDao ;

    public AlphaService() {
        System.out.println("实例化AlphaService");
    }

    @PostConstruct/*在构造器之后调用*/
    public void init(){
        System.out.println("初始化AlphaService");
    }

    @PreDestroy // 在销毁对象之前调用
    public void destroy(){
        System.out.println("销毁AlphaService");
    }

    public String find(){
        return  alphaDao.select();
    }



}
